package com.yantong.service;

import com.yantong.pojo.CommisLogsParams;
import com.yantong.pojo.CommissionLog;
import com.yantong.utils.PageUtils;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 佣金记录服务
 * @author kanghaixin
 * @date 2018/9/18.21:18
 */
public interface CommissionService {
    /**
     * 佣金记录列表
     *
     * @param params
     * @param offset
     * @param limit
     * @return
     */
    PageUtils<CommissionLog> listCommissionLogs(CommisLogsParams params, int offset, int limit);

    BigDecimal countCommissionLogs(CommisLogsParams params);

    /**
     * 佣金记录 不分页
     *
     * @param params
     * @return
     */
    List<CommissionLog> listCommissionLogs(CommisLogsParams params);

    Double commissionTotal(Long mid);

    /**
     * 手动佣金发放
     * @param id
     * @param userId
     * @param username
     * @return
     */
    int grant(Long id, Long userId, String username);

    /**
     * 佣金发放
     * @param cl
     * @return
     */
    int grant(CommissionLog cl, String remark);

    /**
     * 新增佣金记录
     * @param log
     * @return
     */
    void saveLog(CommissionLog log);

    /**
     * 自动发放佣金，使用场景1,收货7天后自动完成订单
     * @param orderProductId
     * @return
     */
    void autoGrant(Long orderProductId);

    /**
     * 会员累积佣金
     * @param mid
     * @param isGrant 0-未发放，1-已发放
     * @return
     */
    double commissionCount(Long mid, Integer isGrant);

    /**
     * 获取门店佣金/提成
     * @param mid 门店ID
     * @param timeType 时间类型，NULL-全部，0-今日，1-本周，2-本月
     * @param offset
     * @param limit
     * @return
     */
    Map<String,Object> getMidGrantCommissionInfo(Long mid, Integer timeType, int offset, int limit);

    /**
     * 将订单相关的id置为无效
     *
     * @param orderId 订单id
     * @param productId 商品id
     * @return int
     * @author liaozhaogui
     * @date 2020/9/26 22:24
     */
    int updateByOrderId(Long orderId, Long productId);


    /**
     * 将订单相关的id置为无效
     *
     * @param orderId 订单id
     * @return int
     * @author liaozhaogui
     * @date 2020/9/26 22:24
     */
    int updateCommissionByOrderId(Long orderId);

    List<CommissionLog> selectByUserAgentCommission();

    int activeCommissionLog(Long orderId);
}
